package com.ruoyi.web.controller.asset;

import com.ruoyi.asset.domain.*;
import com.ruoyi.asset.service.AssetsCategoryService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "api/assetCategory")
@Api(value = "asset", tags = "资产分类查询")
public class AssetCategoryController extends BaseController {

    @Resource
    private AssetsCategoryService assetsCategoryService;

    @PostMapping(value = "categoryTree")
    @ApiOperation(value = "资产分类列表树")
    public AjaxResult categoryTree(@RequestBody GetAssetsCategoryTreeVo evt){
        return success(assetsCategoryService.categoryTree(evt));
    }

    @PostMapping(value = "categoryInfo")
    @ApiOperation(value = "资产分类详情")
    public AjaxResult categoryInfo(@RequestBody GetAssetsCategoryInfoVo evt){
        return success(assetsCategoryService.categoryInfo(evt));
    }

//    @PostMapping(value = "list")
//    @ApiOperation(value = "资产分类列表")
//    @Log(title = "资产分类查询", action = "资产分类列表", type = "1000")
//    public Result<?> list(@RequestBody GetAssetsListVo evt){
//        return assetsCategoryService.list(evt);
//    }

//    @PostMapping(value = "get")
//    @ApiOperation(value = "产品分类详情")
//    @Log(title = "资产分类查询", action = "资产分类详情", type = "1000")
//    public Result<?> get(@RequestBody GetAssetsInfoVo evt){
//        return assetsCategoryService.get(evt);
//    }

    @PostMapping(value = "categoryInsert")
    @ApiOperation(value = "资产分类新增")
    @Log(title = "资产分类新增", businessType = BusinessType.INSERT)
    public AjaxResult categoryInsert(@RequestBody AssetsCategoryChangeVo evt){
        return toAjax(assetsCategoryService.categoryInsert(evt));
    }

    @PostMapping(value = "categoryUpdate")
    @ApiOperation(value = "资产分类编辑")
    @Log(title = "资产分类编辑", businessType = BusinessType.UPDATE)
    public AjaxResult categoryUpdate(@RequestBody AssetsCategoryChangeVo evt){
        return toAjax(assetsCategoryService.categoryUpdate(evt));
    }

    @PostMapping(value = "categoryDelete")
    @ApiOperation(value = "资产分类删除")
    @Log(title = "资产分类删除", businessType = BusinessType.DELETE)
    public AjaxResult categoryDelete(@RequestBody AssetsCategoryDeleteVo evt){
        return toAjax(assetsCategoryService.categoryDelete(evt));
    }
}
